<template>
  <view class="test-container">
    <view class="test-header">
      <text class="test-title">魔方比赛房间测试</text>
    </view>
    
    <view class="test-content">
      <view class="test-section">
        <text class="section-title">测试功能</text>
        <view class="test-buttons">
          <button class="test-btn" @click="testCubeBattleRoom">打开魔方比赛房间</button>
          <button class="test-btn" @click="testWithRoomId">使用房间ID打开</button>
        </view>
      </view>
      
      <view class="test-section">
        <text class="section-title">测试参数</text>
        <view class="param-input">
          <text class="param-label">房间ID:</text>
          <input class="param-input-field" v-model="testRoomId" placeholder="输入房间ID" />
        </view>
        <view class="param-input">
          <text class="param-label">房间名称:</text>
          <input class="param-input-field" v-model="testRoomName" placeholder="输入房间名称" />
        </view>
      </view>
      
      <view class="test-section">
        <text class="section-title">布局测试</text>
        <view class="layout-buttons">
          <button class="layout-btn" @click="testLayout(1)">1个席位 (全屏)</button>
          <button class="layout-btn" @click="testLayout(2)">2个席位 (左右)</button>
          <button class="layout-btn" @click="testLayout(3)">3个席位 (4宫格)</button>
          <button class="layout-btn" @click="testLayout(4)">4个席位 (4宫格)</button>
          <button class="layout-btn" @click="testLayout(8)">8个席位 (网格)</button>
          <button class="layout-btn" @click="testLayout(16)">16个席位 (网格)</button>
        </view>
      </view>
      
      <view class="test-section">
        <text class="section-title">3D魔方测试</text>
        <view class="cube3d-test">
          <text class="test-note">测试3D魔方渲染效果</text>
          <button class="test-btn" @click="testCube3D">测试3D魔方</button>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue'

const testRoomId = ref('test-room-001')
const testRoomName = ref('测试比赛房间')

const testCubeBattleRoom = () => {
  uni.navigateTo({
    url: `/views/cube-battle-room?roomId=${testRoomId.value}&roomName=${encodeURIComponent(testRoomName.value)}`
  })
}

const testWithRoomId = () => {
  if (!testRoomId.value.trim()) {
    uni.showToast({
      title: '请输入房间ID',
      icon: 'none'
    })
    return
  }
  
  uni.navigateTo({
    url: `/views/cube-battle-room?roomId=${testRoomId.value}&roomName=${encodeURIComponent(testRoomName.value || '测试房间')}`
  })
}

const testLayout = (seatCount) => {
  const roomId = `test-layout-${seatCount}`
  const roomName = `测试布局 - ${seatCount}个席位`
  
  uni.navigateTo({
    url: `/views/cube-battle-room?roomId=${roomId}&roomName=${encodeURIComponent(roomName)}&testSeats=${seatCount}`
  })
}

const testCube3D = () => {
  const roomId = 'test-cube3d'
  const roomName = '3D魔方测试'
  
  uni.navigateTo({
    url: `/views/cube-battle-room?roomId=${roomId}&roomName=${encodeURIComponent(roomName)}&testSeats=1`
  })
}
</script>

<style lang="scss" scoped>
.test-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 40rpx;
}

.test-header {
  text-align: center;
  margin-bottom: 60rpx;
  
  .test-title {
    font-size: 48rpx;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.3);
  }
}

.test-content {
  .test-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20rpx;
    padding: 30rpx;
    margin-bottom: 30rpx;
    box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.15);
    
    .section-title {
      font-size: 32rpx;
      font-weight: bold;
      color: #333;
      margin-bottom: 20rpx;
      display: block;
    }
    
    .test-buttons {
      display: flex;
      flex-direction: column;
      gap: 20rpx;
      
      .test-btn {
        height: 80rpx;
        border: none;
        border-radius: 12rpx;
        font-size: 28rpx;
        font-weight: bold;
        color: #fff;
        background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
      }
    }
    
    .layout-buttons {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 15rpx;
      
      .layout-btn {
        height: 70rpx;
        border: none;
        border-radius: 10rpx;
        font-size: 24rpx;
        font-weight: bold;
        color: #fff;
        background: linear-gradient(135deg, #6f42c1 0%, #5a32a3 100%);
      }
    }
    
    .cube3d-test {
      text-align: center;
      
      .test-note {
        display: block;
        font-size: 24rpx;
        color: #666;
        margin-bottom: 20rpx;
      }
    }
    
    .param-input {
      display: flex;
      align-items: center;
      margin-bottom: 20rpx;
      
      .param-label {
        width: 120rpx;
        font-size: 26rpx;
        color: #666;
        font-weight: 500;
      }
      
      .param-input-field {
        flex: 1;
        height: 60rpx;
        padding: 0 15rpx;
        border: 2rpx solid #ddd;
        border-radius: 8rpx;
        font-size: 26rpx;
        background: #fff;
        
        &:focus {
          border-color: #667eea;
        }
      }
    }
  }
}
</style> 